package com.ylsk.check.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ylsk.check.domain.dto.InsOperationUnitDTO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ylsk.common.annotation.Log;
import com.ylsk.common.core.controller.BaseController;
import com.ylsk.common.core.domain.AjaxResult;
import com.ylsk.common.enums.BusinessType;
import com.ylsk.check.domain.InsOperationUnit;
import com.ylsk.check.service.IInsOperationUnitService;
import com.ylsk.common.utils.poi.ExcelUtil;
import com.ylsk.common.core.page.TableDataInfo;

/**
 * 高速运营单位Controller
 *
 * @author ysy
 * @date 2023-12-03
 */
@RestController
@RequestMapping("/check/insOperationUnit")
public class InsOperationUnitController extends BaseController
{
    @Autowired
    private IInsOperationUnitService insOperationUnitService;

    /**
     * 查询高速运营单位列表
     */
    @PreAuthorize("@ss.hasPermi('check:insOperationUnit:list')")
    @GetMapping("/list")
    public TableDataInfo list(InsOperationUnit insOperationUnit)
    {
        startPage();
        List<InsOperationUnit> list = insOperationUnitService.selectInsOperationUnitList(insOperationUnit);
        return getDataTable(list);
    }

    /**
     * 导出高速运营单位列表
     */
    @PreAuthorize("@ss.hasPermi('check:insOperationUnit:export')")
    @Log(title = "高速运营单位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InsOperationUnit insOperationUnit)
    {
        List<InsOperationUnit> list = insOperationUnitService.selectInsOperationUnitList(insOperationUnit);
        ExcelUtil<InsOperationUnit> util = new ExcelUtil<InsOperationUnit>(InsOperationUnit.class);
        util.exportExcel(response, list, "高速运营单位数据");
    }

    /**
     * 获取高速运营单位详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:insOperationUnit:query')")
    @GetMapping(value = "/{operationUnitId}")
    public AjaxResult getInfo(@PathVariable("operationUnitId") Long operationUnitId)
    {
        return success(insOperationUnitService.selectInsOperationUnitByOperationUnitId(operationUnitId));
    }

    /**
     * 新增高速运营单位
     */
    @PreAuthorize("@ss.hasPermi('check:insOperationUnit:add')")
    @Log(title = "高速运营单位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InsOperationUnitDTO insOperationUnitDTO)
    {
        return toAjax(insOperationUnitService.insertInsOperationUnit(insOperationUnitDTO));
    }

    /**
     * 修改高速运营单位
     */
    @PreAuthorize("@ss.hasPermi('check:insOperationUnit:edit')")
    @Log(title = "高速运营单位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InsOperationUnitDTO insOperationUnitDTO)
    {
        return toAjax(insOperationUnitService.updateInsOperationUnit(insOperationUnitDTO));
    }

    /**
     * 删除高速运营单位
     */
    @PreAuthorize("@ss.hasPermi('check:insOperationUnit:remove')")
    @Log(title = "高速运营单位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{operationUnitIds}")
    public AjaxResult remove(@PathVariable Long[] operationUnitIds)
    {
        return toAjax(insOperationUnitService.deleteInsOperationUnitByOperationUnitIds(operationUnitIds));
    }
}
